﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Microsoft.Xna.Framework.Net;
using Microsoft.Xna.Framework.Storage;

namespace h2100
{
    /// <summary>
    /// Quản lý tất cả các nhân vật (người chơi điều khiển) trong game
    /// </summary>
    public class hCharacterManager : hEntityManager
    {
        private List<hUnit> _chars = new List<hUnit>();

        public void initPrototypes(ContentManager contentmanager)
        {
            _nprototype = 1;
            _prototype = new hUnit[_nprototype];

            _prototype[0] = new hUnit();
            _prototype[0].init(contentmanager, 15, "Angel");
            //((hCharacter)_prototype[0]).nDelay = 1;
        }

        public override hVisibleGameEntity createObject(int idx)
        {
            if (idx < 0 || idx >= _nprototype)
                return null;
            _chars.Add((hUnit)_prototype[idx].clone());
            return _chars.Last();
        }

        public void update(hParams args, GameTime time, hMapManager mapManager)
        {
             for (int i = 0; i < _chars.Count; i++)
            {
                _chars[i].update(args, time,mapManager);
            }
        }

        public void draw(GameTime gtime, SpriteBatch spriteBatch)
        {
            for (int i = 0; i < _chars.Count; i++)
            {
                _chars[i].draw(gtime, spriteBatch);
            }
        }

    }
}
